package com.example.ordersystem.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;


@Component
public class SelfErrorPageRegister implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        //注冊异常页面
        ErrorPage sqlEx=new ErrorPage(Exception.class,"/WEB-INF/jsp/error/exception.jsp");
        registry.addErrorPages(sqlEx);

        //注册404页面
        ErrorPage e500=new ErrorPage(HttpStatus.NOT_FOUND,"/WEB-INF/jsp/error/404.jsp");
        registry.addErrorPages(e500);
    }
}